package com.yunbiji.demo.controller;

import com.yunbiji.demo.entity.CnShare;
import com.yunbiji.demo.service.CnShareService;
import com.yunbiji.demo.util.NoteResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CnShare)表控制层
 *
 * @author makejava
 * @since 2021-06-02 08:38:33
 */
@Controller
@RequestMapping("cnShare")
public class CnShareController {
    /**
     * 服务对象
     */
    @Resource
    private CnShareService cnShareService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public CnShare selectOne(String id) {
        return this.cnShareService.queryById(id);
    }


    @RequestMapping("/add.do")
    @ResponseBody
    public NoteResult<Object> execute1(String noteId) {
        NoteResult<Object> result = cnShareService.shareNote(noteId);
        return result;
    }


    @RequestMapping("/search.do")
    @ResponseBody
    public NoteResult<List<CnShare>> execute2(String keyword) {
        NoteResult<List<CnShare>> result = cnShareService.searchNote(keyword);
        return result;
    }


}